package com.cn.admin.unit;

import com.cn.admin.vo.label.LabelVo;
import com.cn.admin.vo.order.OrderVo;
import com.cn.dto.LabelDto;
import com.cn.dto.OrderDTO;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.util.List;

public class Tool {
    private static LabelVo labelVo;
    //    @Autowired
//    LabelDto labelDto;
    private static LabelDto labelDto;

    public static List<LabelVo> vo(List<LabelDto> labelDto) {
        List<LabelVo> list = null;
        for (int i = 0; i < labelDto.size(); i++) {
            labelVo.setName(labelDto.get(i).getName());
            list.add(labelVo);

        }
        return list;
    }
    public static List<LabelDto> Dto(List<LabelVo> labelVos) {
        List<LabelDto> list = null;
        for (int i = 0; i < labelVos.size(); i++) {
            labelDto.setName(labelVos.get(i).getName());
            list.add(labelDto);

        }
        return list;
    }
    ;

    public static LabelDto VoToDto(LabelVo labelVo) {
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        LabelDto labelDto = mapperFactory.getMapperFacade().map(labelVo, LabelDto.class);
        return labelDto;

    }
    public static LabelVo DtoToVo(LabelDto labelDto) {
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        LabelVo labelVo = mapperFactory.getMapperFacade().map(labelDto, LabelVo.class);
        return labelVo;

    }
    public static OrderDTO OVoToDto(OrderVo orderVo) {
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        OrderDTO orderDTO = mapperFactory.getMapperFacade().map(orderVo, OrderDTO.class);
        return orderDTO;}
    public static OrderVo ODtoToVO(OrderDTO orderDTO) {
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        OrderVo orderVo = mapperFactory.getMapperFacade().map(orderDTO, OrderVo.class);
        return orderVo;}
}
